﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKArchMethodLibrary.Utils;

namespace Parapet.Analyzer
{
	public class RoomData
	{
		public List<RoomData.BoundingSegment> WallSegmentList
		{
			get
			{
				return this.m_WallSegmentList;
			}
		}

		public bool FindWallId(ElementId wallId, ref List<RoomData.BoundingSegment> boundingSegments)
		{
			foreach (RoomData.BoundingSegment boundingSegment in this.m_WallSegmentList)
			{
				if (boundingSegment.FindWallId(wallId))
				{
					boundingSegments.Add(boundingSegment);
				}
			}
			return boundingSegments.Count != 0;
		}

		public RoomData(RoomData rhs)
		{
			this.m_WallSegmentList.Clear();
			this.m_WallSegmentList.AddRange(rhs.WallSegmentList);
		}

		public RoomData(List<RoomData.BoundingSegment> wallSegmentList)
		{
			this.m_WallSegmentList.Clear();
			this.m_WallSegmentList.AddRange(wallSegmentList);
		}

		private List<RoomData.BoundingSegment> m_WallSegmentList = new List<RoomData.BoundingSegment>();

		public class BoundingSegment
		{
			public EdgeInfo Curve
			{
				get
				{
					return this.m_Curve;
				}
			}

			public ElementId WallId
			{
				get
				{
					return this.m_WallId;
				}
			}

			public bool FindWallId(ElementId wallId)
			{
				return wallId.IntegerValue == this.m_WallId.IntegerValue;
			}

			public BoundingSegment(RoomData.BoundingSegment rhs)
			{
				this.m_Curve = rhs.m_Curve;
				this.m_WallId = rhs.m_WallId;
			}

			public BoundingSegment(EdgeInfo curve, ElementId wallId)
			{
				this.m_Curve = curve;
				this.m_WallId = wallId;
			}

			private EdgeInfo m_Curve;

			private ElementId m_WallId;
		}
	}
}
